package com.buli.blmall.admin.system.controller;

import org.springframework.web.bind.annotation.*;
import com.buli.blmall.admin.system.service.SysRoleService;
import com.buli.blmall.admin.system.vo.SysRoleVO;
import com.buli.blmall.admin.base.BaseController;
import com.buli.blmall.admin.common.response.Result;
import java.util.List;
import lombok.AllArgsConstructor;


/**
 * <p>
 * 角色 控制器
 * </p>
 *
 * @author buli
 * @since 2025-02-27
 */
@RestController
@RequestMapping("system/sys_role")
@AllArgsConstructor
public class SysRoleController extends BaseController {

    private SysRoleService sysRoleService;

    /**
     * 查询角色详情
     *
     * @param id 角色ID
     */
    @GetMapping("/{id}")
    public Result<SysRoleVO> getsysRole(@PathVariable Long id) {
        return Result.success(sysRoleService.info(id));
    }

    /**
     * 查询角色集合
     *
     * @param sysRoleVo
     */
    @GetMapping("/list")
    public Result<List<SysRoleVO>> listSysRole(SysRoleVO sysRoleVo) {
        return Result.success(sysRoleService.queryList(sysRoleVo));
    }

    /**
     * 添加角色
     * @param sysRoleVo
     */
    @PostMapping("/add")
    public Result<Boolean> addSysRole(@RequestBody SysRoleVO sysRoleVo) {
        return Result.success(sysRoleService.add(sysRoleVo));
    }

    /**
     * 修改角色
     * @param sysRoleVo
     */
    @PutMapping("/edit")
    public Result<Boolean> editSysRole(@RequestBody SysRoleVO sysRoleVo) {
        return Result.success(sysRoleService.edit(sysRoleVo));
    }

    /**
     * 删除角色
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Result<Boolean> removeSysRole(@PathVariable Long id) {
        return Result.success(sysRoleService.removeById(id));
    }

}

